Page({
  onLoad: function (options) {
    setInterval(() => {
      var data = wx.getStorageSync('data')//个人资料
      this.setData({
        avatarUrl: data.avatarUrl,
        name: data.nickname
      })
    }, 100)
  },
  getphone() {
    wx.navigateTo({
      url: '/pages/phone/phone',
    })
  },
  //头像遮盖层
  hidedType: function (e) {
    this.setData({
      showdDialog: false
    })
  },
  //头像
  sculpture: function (e) {
    this.setData({
      showdDialog: true
    })
  },
  //从相册选择
  chooseImage() {
    wx.chooseImage({
      count: 1, //默认9
      sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
      sourceType: ['album'], //从相册选择
      success: (res) => {
        if (this.data.imgList.length != 0) {
          this.setData({
            imgList: this.data.imgList.concat(res.tempFilePaths)
          })
          this.data.user.img = this.data.imgList
          wx.setStorageSync('muserlist', this.data.user)//添加
        } else {
          this.setData({
            imgList: res.tempFilePaths
          })
          this.data.user.img = this.data.imgList
          wx.setStorageSync('muserlist', this.data.user)
        }
      }
    });
    this.setData({
      showdDialog: false
    })
  },
  //   拍照
  takePhoto: function () {
    wx.chooseImage({
      count: 1, //默认9
      sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
      sourceType: ['camera'], //从相机
      success: (res) => {
        if (this.data.imgList.length != 0) {
          this.setData({
            imgLists: this.data.imgList.concat(res.tempFilePaths)
          })
          this.data.user.img = this.data.imgLists
          wx.setStorageSync('muserlist', this.data.user)
        } else {
          this.setData({
            imgLists: res.tempFilePaths
          })
          this.data.user.img = this.data.imgLists
          wx.setStorageSync('muserlist', this.data.user)
        }
      }

    });
    this.setData({
      showdDialog: false
    })
  },
})